//
//  MyBoomModel.m
//  Liuhe
//
//  Created by zr on 2018/8/20.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "MyBoomModel.h"

@implementation MyBoomModel

+(instancetype)modelWithDictionary:(NSDictionary *)dic{
    
    MyBoomModel *model =[[MyBoomModel alloc] init];
    
    [model setValuesForKeysWithDictionary:dic];
    
    return model;
}


+(void)myBoomModelWithSucess:(void (^)(NSArray<MyBoomModel *> *))sucessBlock error:(void (^)(void))errorBlock{
    
    //    NSDictionary * parameters;
    NSString * user_id = DEF_GET_OBJECT(@"user_id");
    
    NSDictionary * dict = @{@"user_id":user_id};
    
    [[NetworkTool sharedTools] POST:@"/index/Liuheonline/getburst" parameters:dict progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
        //        NSLog(@"====%@",responseObject);
        NSString * msg = responseObject[@"msg"];
        
        if ([msg isEqualToString:@"无数据"]) {
            
            NSArray * array = nil;
            sucessBlock(array);
            
        }else{
            
            NSArray * paramArray = responseObject[@"data"];
            
            //            NSLog(@"==%@",paramArray);
            
            NSMutableArray *mArray = [NSMutableArray array];
            
            [paramArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                
                MyBoomModel * model = [MyBoomModel modelWithDictionary:obj];
                
                [mArray addObject:model];
                
            }];
            
            if(sucessBlock){
                sucessBlock(mArray.copy);
            }
        }
        
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
}


- (void)setValue:(id)value forKey:(NSString *)key{
    
    if ([key isEqualToString:@"id"]) {
        
        self.ID = value;
    }else{
        
        [super setValue:value forKey:key];
    }
    
}


-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
}

@end
